import {Form, Switch} from 'antd';
import React from 'react';
import "./index.css";
import {FormSwitchProps} from "@/assets/components/formSwitchProps";

/**
 * form开关组件
 * @param props
 * @constructor
 */
const FormSwitch = (props: FormSwitchProps) => {
  return (
    <Form.Item key={props.name} name={props.name} label={props.label}>
      <Switch
        key={props.form.getFieldValue(props.name)}
        defaultChecked={props.form.getFieldValue(props.name) === "1" ? true : false}
      />
    </Form.Item>
  )
};

export default FormSwitch;
